<template>
  <div class="add">
    <div class="add-wrap">
      <van-address-edit
        :area-list="areaList"
        show-set-default
        :area-columns-placeholder="['请选择', '请选择', '请选择']"
        @save="onSave"
        @change-detail="onChangeDetail"
      />
    </div>
  </div>
</template>

<script>
import areaList from "@/assets/js/area.js";
export default {
  data() {
    return {
      areaList: areaList,
      show: true,
      formData: {},
    };
  },
  methods: {
    onSave(content) {
      this.formData = {
        name: content.name,
        phone: content.tel,
        address:
          content.province +
          content.city +
          content.county +
          content.addressDetail,
        default: content.isDefault ? 1 : 2,
      };
      this.submit();
    },
    onChangeDetail() {
      // 改变
    },
    submit() {
      this.$axios.put("/address/address", this.formData).then((res) => {
        if (res.data.code == 200) {
          this.$toast.success(res.data.msg);
          this.$router.go(-1);
        } else {
          this.$toast.fail(res.data.msg);
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.add {
  padding-top: 1.1728rem;
  padding-bottom: 1.4928rem;
  .add-wrap {
  }
}
</style>